<#import "base.ftl" as base/>
<#import "spring.ftl" as spring/>

<@base.baseTemplate title="toscan">
	<div style="display:none; margin-bottom: 10px;" id="scanfinishedbox">
		<div class="infobox"><@spring.message "scanfinished"/></div>
	</div>
	<form style="display:none;" id="startscanform" name="user" action="${rc.getContextPath()}/startscan" method="get">
		<input type="submit" value="<@spring.message "startscan"/>" class="submit button" />
	</form>
	<div style="display:none;" id="loading-indicator">
		<div><b><@spring.message "scanIsRunning"/></b></div>
		<div><img src="${rc.getContextPath()}/resources/images/loader.gif" /></div>
	</div>
	<div id="scan-messages">
	</div>
	<script type="text/javascript">
		var scanIsRunning = false;
		var auto_refresh = setInterval(function (){
			$.get('${rc.getContextPath()}/isScanRunning', function(data) {
				if(data == 'true') {
					$('#scan-messages').load('${rc.getContextPath()}/getScanLogMessages');
					scanIsRunning = true;
					$('#scanfinishedbox').fadeOut("slow");
					$('#startscanform').fadeOut("slow");
					$('#loading-indicator').fadeIn("slow");
					$('#scan-messages').fadeIn("slow");
				} else {
					$('#startscanform').fadeIn("slow");
					$('#loading-indicator').fadeOut("slow");
					$('#scan-messages').fadeOut("slow");
					if(scanIsRunning){
						scanIsRunning = false;
						$('#scanfinishedbox').fadeIn("slow");
					}
				}
			});
		}, 2000);
	</script>
</@base.baseTemplate>